package main

import (
	"flag"
	"log"
	"os"
	"os/signal"
	"time"
	"wxp2p/client"
	"wxp2p/common"
)

// server-client
var helper_server_addr = flag.String("addr", "43.138.80.3:8018", "http service address")

// var helper_server_addr = flag.String("addr", "127.0.0.1:8018", "信号服务地址")
var serverclientId = flag.String("id", "wangxue", "客户端标识符")
var local_port = flag.String("port", "3389", "本地端口")

func main() {
	flag.Parse()
	log.Println("服务端模式")
	interrupt := make(chan os.Signal, 1)
	signal.Notify(interrupt, os.Interrupt)
	client.G_ClientType = common.EServerClient
	go client.RunWebrtcAnswer(*serverclientId)
	go client.ServerRecvChanHandler(*local_port)
	go client.LinkSignalServer(*helper_server_addr, *serverclientId)
	go client.RegClientToSignalServer(*serverclientId)

	<-interrupt
	log.Println("user interrupt,waitting for 1 secend")
	<-time.After(time.Second)
}
